let request = require('request');


module.exports = {
    curlGet: function ({url, query = {}}) {
        return new Promise((resolve, reject) => {
            request({
                url: url,
                method: "GET",
                qs: query,
            }, function (error, response, body) {
                if (!error && response.statusCode === 200) {
                    resolve(JSON.parse(body));
                } else {
                    reject(`api ${url} error.`);
                }
            });
        });

    },

}

